
class Node<T extends Comparable<T>> {
    public Node<T> left;
    public Node<T> right;
    public T value;
    public void addRight(T v) { right = new Node<T>(v); }
    public void addLeft(T v) { left = new Node<T>(v); }
    public boolean isLeaf() { return ((left==null)&&(right==null)); }
    public boolean leftIsLarger() {  //Should not be called by a leaf
        if (left == null) return false;
        if (right == null) return true;
        return (left.value.compareTo(right.value) > 0);
    }
    public boolean isBigParent() {
        if (value == null) return false;
        boolean biggerThanLeft = true;
        if (left != null) {
            if (left.value != null) biggerThanLeft = (value.compareTo(left.value) > 0);
        }
        boolean biggerThanRight = true;
        if (right != null) {
            if (right.value != null) biggerThanRight = (value.compareTo(right.value) > 0);
        }
        return ((biggerThanLeft)&&(biggerThanRight)); 
    }
    //Constructor
    Node(T v) {
        left = null;
        right = null;
        value = v;
    }
}   